package pers.wj.springcloud.service;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import pers.wj.springcloud.entities.Employee;

import java.util.List;

/**
 * 服务降级，一个实现了FallbackFactory接口的类DeptClientServiceFallbackFactory
 *
 * @author wangjie
 * @version V1.0
 * @date 2020/2/28
 */
@Component
public class ClientServiceFallbackFactory implements FallbackFactory<ClientService> {
	@Override
	public ClientService create(Throwable throwable)
	{
		return new ClientService() {
			@Override
			public Employee get(long id)
			{
				return new Employee().setId((int)id).setLastName("该ID：" + id + "没有没有对应的信息,Consumer客户端提供的降级信息,此刻服务Provider已经关闭");
			}

			@Override
			public List<Employee> list()
			{
				return null;
			}

			@Override
			public boolean add(Employee dept)
			{
				return false;
			}
		};
	}
}
